#include "zos_config.h"

#ifdef BOARD_USING_MPU6XXX
#include <zos.h>
#include "mpu6xxx.h"



static zos_err_t demo_mpu6xxx(int argc, char *argv[])
{
    struct mpu6xxx_device *dev;
    struct mpu6xxx_3axes accel, gyro;
    int i;

    /* Initialize mpu6xxx, The parameter is 0, means auto probing for i2c*/
    dev = mpu6xxx_init(ZOS_I2C_BUS_0, 0x68);

    if (dev == ZOS_NULL)
    {
        zos_printf("mpu6xxx init failed\n");
        return ZOS_ERROR;
    }
    zos_printf("mpu6xxx init succeed\n");

    for (i = 0; i < 5; i++)
    {
        mpu6xxx_get_accel(dev, &accel);
        mpu6xxx_get_gyro(dev, &gyro);

        zos_printf("accel.x = %3d, accel.y = %3d, accel.z = %3d ", accel.x, accel.y, accel.z);
        zos_printf("gyro.x = %3d gyro.y = %3d, gyro.z = %3d\n", gyro.x, gyro.y, gyro.z);

        zos_task_delay(100);
    }

    mpu6xxx_deinit(dev);

    return ZOS_EOK;
}

#include "shell.h"

SHELL_EXPORT_CMD(demo_mpu6xxx,demo_mpu6xxx, mpu6xxx demo);



#endif